import React from 'react'
import "../css/inputox.css"
import EventEmitter from "../event"
class InputBox extends React.Component {
    constructor(props) {
        super(props)
        this.state = {

        }
    }
    componentDidMount() {
        this.setState({

        })
    }
    render() {
        return (
            <div className="inputss">
                <input type="text" ref="input" />
                <button onClick={() => {
                    let value = this.refs.input.value;
                    console.log(value);
                    if (value.length == 0) {
                        alert("输入不能为空")
                        return;
                    }

                    var data = new Date();
                    var datestr = `${data.getFullYear()}年${data.getMonth() + 1}月${data.getDate()}日${data.getHours()}时${data.getMinutes()}分${data.getSeconds()}秒`;

                    var message = {
                        content: value,
                        data: datestr
                    }
                    EventEmitter.emit("sendss", message);

                    this.refs.input.value = "";
                }}>提交</button>
            </div>


        )
    }
}

export default InputBox